var t = require;
var e = module;
var o = exports;
var n =
    (this && this.__extends) ||
    (function () {
        var t = function (e, o) {
            return (t =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                })(e, o);
        };
        return function (e, o) {
            function n() {
                this.constructor = e;
            }
            t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
        };
    })();
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("fsm"),
    a = (function () {
        function t(t, e) {
            (this.time = t), r.changeState(this, e ? c : s);
        }
        return (
            (t.prototype.progress = function () {
                return this.state.progress();
            }),
            (t.prototype.is_ready = function () {
                return this.state.is_ready();
            }),
            (t.prototype.enter_cd = function () {
                this.state.enter_cd();
            }),
            (t.prototype.update = function (t) {
                this.state.onUpdate(t);
            }),
            t
        );
    })();
o.default = a;
var i = (function () {
        function t() {}
        return (
            (t.prototype.progress = function () {
                throw new Error("Method not implemented.");
            }),
            (t.prototype.enter_cd = function () {
                throw new Error("Method not implemented.");
            }),
            (t.prototype.is_ready = function () {
                return !1;
            }),
            (t.prototype.onEnter = function () {}),
            (t.prototype.onUpdate = function (t) {}),
            (t.prototype.onExit = function () {}),
            t
        );
    })(),
    s = (function (t) {
        function e() {
            return (null !== t && t.apply(this, arguments)) || this;
        }
        return (
            n(e, t),
            (e.prototype.onEnter = function () {
                this.time = this.context.time;
            }),
            (e.prototype.onUpdate = function (t) {
                (this.time -= t), this.time <= 0 && r.changeState(this.context, c);
            }),
            (e.prototype.progress = function () {
                return this.time / this.context.time;
            }),
            e
        );
    })(i),
    c = (function (t) {
        function e() {
            return (null !== t && t.apply(this, arguments)) || this;
        }
        return (
            n(e, t),
            (e.prototype.is_ready = function () {
                return !0;
            }),
            (e.prototype.enter_cd = function () {
                r.changeState(this.context, s);
            }),
            (e.prototype.progress = function () {
                return 0;
            }),
            e
        );
    })(i);
